<script type="text/javascript" src="{%base_url%}resources/tinymce/tiny_mce.js"></script>
<script type="text/javascript" src="{%base_url%}scripts/items.js"></script>
<div>
<h1>Добавление видео</h1>
<form id="video-form" action="{%link[{%class%}]%}" method="post" enctype="multipart/form-data">
<input type="hidden" name="edit" value="1" />

<table cellpadding="0" cellspacing="0">
<col />
<col width="10" />
<col />
<tr>
   <td valign="top">
      <table>
      <tr>
         <td colspan="3">
            <h3>Основная информация</h3>
         </td>
      </tr>
      <tr>
         <td class="w100" valign="top">
            Название <span class="required">*</span>
         </td>
         <td>
            <input type="text" name="title" value="{%title%}" size="50" class="i" />
            {%error_title%}
         </td>
      </tr>
      <tr>
         <td class="w100" valign="top">
            Оригинальное название
         </td>
         <td>
            <input type="text" name="orig_title" value="{%orig_title%}" size="50" class="i" />
            {%error_orig_title%}
         </td>
      </tr>
      <tr>
         <td class="w100" valign="top">
            Изображение
         </td>
         <td>
            <input type="hidden" name="hidden_image" value="{%image%}" />
            <input type="file" name="image" size="30" class="i" />
            {%error_image%}
         </td>
      </tr>
      {%image_exists%}
      <tr id="preview_image">
         <td class="w100" valign="top">
            &nbsp;
         </td>
         <td nowrap="nowrap">
            <img src="{%base_url%}{%widget[thumbnail,src={%image%},size=100x100]%}" alt="" align="left" />
            <img src="{%base_url%}images/admin/delete.gif" alt="" title="Удалить" onclick="remove_image()" />
         </td>
      </tr>
      {%/image_exists%}
      <tr>
         <td class="w100" valign="top">
            Год выхода
         </td>
         <td>
            <input type="text" name="year" value="{%year%}" size="8" class="i" />
            {%error_year%}
         </td>
      </tr>
      <tr>
         <td class="w100" valign="top">
            Продолжительность
         </td>
         <td>
            <input type="text" name="length" value="{%length%}" class="timepicker i" />
            {%error_length%}
         </td>
      </tr>
      </table>
   </td>
   <td></td>
   <td valign="top">
      <table cellpadding="0"  cellspacing="0">
      <tr>
         <td>
            <h3>Трейлер</h3>
         </td>
      </tr>
      <tr>
         <td>
            <textarea name="trailer" class="i wide">{%trailer%}</textarea>
            {%error_trailer%}
         </td>
      </tr>
      </table>
   </td>
</tr>
<tr>
   <td colspan="3">
      &nbsp;
   </td>
</tr>
<tr>
   <td valign="top">
      <table cellpadding="0"  cellspacing="0">
      <tr>
         <td>
            <h3>Жанры</h3>
         </td>
      </tr>
      <tr>
         <td>
            <div class="rollbox">
               {%genres%}
               <div><label>{%checkbox%} {%title%}</label></div>
               {%/genres%}
            </div>
         </td>
      </tr>
      </table>
   </td>
   <td></td>
   <td valign="top">
      <table cellpadding="0"  cellspacing="0">
      <tr>
         <td>
            <h3>Страны</h3>
         </td>
      </tr>
      <tr>
         <td>
            <div class="rollbox">
               {%countries%}
               <div><label>{%checkbox%} {%title%}</label></div>
               {%/countries%}
            </div>
         </td>
      </tr>
      </table>
   </td>
</tr>
<tr>
   <td colspan="3">
      &nbsp;
   </td>
</tr>
<tr>
   <td valign="top">
      <table cellpadding="0"  cellspacing="0">
      <tr>
         <td>
            <h3>Режиссеры</h3>
         </td>
      </tr>
      <tr>
         <td>
            <input type="hidden" name="directors" value="" id="directors" />
            <div id="directors-container" style="width: 320px; height: 120px; overflow: auto; border: 1px solid #999;"></div>
            <a href="{%link[admin_manage_persons,simple,type=directors,KeepThis=true,TB_iframe=true,height=450,width=300]%}" class="thickbox" title="Каталог персон">Добавить персону</a> |
            <a href="{%link[admin_update_person]%}" target="_balnk">Создать новую перосну</a>
            <script type="text/javascript">
            directors = {%directors%};
            for (i in directors) {
                add_person(directors[i].id, directors[i].title, 'directors');
            }
            </script>
         </td>
      </tr>
      </table>
   </td>
   <td></td>
   <td valign="top">
      <table cellpadding="0"  cellspacing="0">
      <tr>
         <td>
            <h3>Актеры</h3>
         </td>
      </tr>
      <tr>
         <td>
            <input type="hidden" name="actors" value="" id="actors" />
            <div id="actors-container" style="width: 320px; height: 120px; overflow: auto; border: 1px solid #999;"></div>
            <a href="{%link[admin_manage_persons,simple,type=actors,KeepThis=true,TB_iframe=true,height=450,width=300]%}" class="thickbox" title="Каталог персон">Добавить персону</a> |
            <a href="{%link[admin_update_person]%}" target="_balnk">Создать новую перосну</a>
            <script type="text/javascript">
            actors = {%actors%};
            for (i in actors) {
                add_person(actors[i].id, actors[i].title, 'actors');
            }
            </script>
         </td>
      </tr>
      </table>
   </td>
</tr>
<tr>
   <td colspan="3">
      &nbsp;
   </td>
</tr>
<tr>
   <td colspan="3">
      <h3>Описание</h3>
   </td>
</tr>
<tr>
   <td valign="top" colspan="3">
      <textarea name="description" id="description" class="i" cols="140" rows="20">{%description%}</textarea>
   </td>
</tr>
<tr>
   <td colspan="3">
      &nbsp;
   </td>
</tr>
<tr>
   <td colspan="3">
      <input type="submit" value="Добавить" class="b" />
   </td>
</tr>
</table>

</form>
</div>
<script type="text/javascript">
function remove_image() {
   jQuery('input[name=hidden_image]').val('');
   jQuery('#preview_image').remove();
}
tinyMCE.init({
   // General options
   mode: "exact",
   elements: "description,rerite-description",
   theme: "advanced",
   plugins: "safari,pagebreak,style,table,advhr,advlink,emotions,iespell,inlinepopups,preview,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,images",

   // Theme options
   theme_advanced_buttons1: "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,formatselect,bullist,numlist,outdent,indent",
   theme_advanced_buttons2: "link,unlink,anchor,image,separator,undo,redo,cleanup,code,separator,sub,sup,charmap",
   theme_advanced_buttons3: "",
   theme_advanced_toolbar_location: "top",
   theme_advanced_toolbar_align: "left",
   theme_advanced_statusbar_location: "bottom",
   theme_advanced_resizing: true,
   relative_urls: false,
   remove_script_host: false,
   document_base_url: "{%base_url%}",
   external_image_list_url: "{%link[admin_manage_images,jslist]%}"
});
jQuery(function() {
   jQuery('input.timepicker').each(function() {
      [h, m, s] = jQuery(this).val().split(':');
      jQuery(this).clock({
         displayFormat: '24',
         defaultHour: h,
         defaultMinute: m,
         defaultSeconds: s,
         seconds: true
      });
   });
   $('#video-form').submit(function() {
      submit_persons('directors');
      submit_persons('actors');
   });
})
</script>
